<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<style>
    .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td{
        padding: 11px;
    }
    .table-striped > tbody > tr:nth-child(odd) > td{
        padding-left: 60px;
    }
    tbody  td{
        font-size: 16px;
    }
</style>
<section id="main-content">
    <section class="wrapper">
                <h3><i class="fa fa-angle-right"></i> 积分核销信息</h3>
                <!-- BASIC FORM ELELEMNTS -->
                <div class="row mt">
                    <div class="col-lg-12">
                        <div class="form-panel" style="height: 500px">
                            <h4 class="mb"><i class="fa"></i>
                                <a class="fancybox" href="{$users.headimgurl}">
                                    <img class="img-responsive" src="{$users.headimgurl}" style="width: 60px;height: 60px;border-radius: 50%;float: left">
                                </a>
                                <span style="display: block; margin-left: 20px;float: left;margin-top: 24px;">{$user.name}</span>
                                <if condition="$ba != NULL">
                                    <a href="{:U('Backs/index')}" class="external-event label label-success" style="margin-left: 40px; float: left;margin-top: 15px;">返回</a>
                                    <else/>
                                    <a href="{:U('info')}" class="external-event label label-success" style="margin-left: 40px; float: left;margin-top: 15px;">返回</a>
                                </if>
                            </h4>
                            <br>
                            <table class="table table-striped table-advance table-hover" style="text-align: left">
                                <!--<h4 style="display: block;margin-top: 45px"><i class="fa fa-angle-right"></i> 用户详细信息：</h4>
                                <hr>-->
                                <thead>
                                <tr>
                                    <th>微信昵称：</th>
                                    <th>姓名：</th>
                                    <th>电话：</th>
                                    <th>积分数：</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>{$users.nickname}</td>
                                    <td>{$users.name}</td>
                                   <!-- <td>
                                        <if condition="$user.sex == 0">
                                            未知
                                        </if>
                                        <if condition="$user.sex == 1">
                                            男
                                        </if>
                                        <if condition="$user.sex == 2">
                                            女
                                        </if>
                                    </td>-->
                                    <td>{$users.phone}</td>
                                    <td><b style="color: red">{$users.covers}</b></td>
                                </tr>
                                </tbody>
                            </table>
                            <div style="margin-top: 5%;margin-left: 30%">
                                <label class="col-sm-2" style="font-weight: bolder;font-size: 16px;margin-top: 8px">核销积分数:</label>
                                <div class="col-sm-3" style="margin-left: -80px;">
                                    <input id="he_one" name="covers"   type="number"  class="form-control" placeholder="最多可核销{$users.covers}">
                                </div>
                            </div>
                            <div>
                                <div class="col-sm-10">
                                    <input type="hidden" id="id" value="{$users.id}">
                                    <input type="hidden" id="he_two" value="{$users.covers}">
                                    <input  type="button" id="tianjia" class="btn btn-theme" value="提交" style="width: 150px;margin-left: 16px;">
                                </div>
                            </div>
                        </div>
                    </div><!-- col-lg-12-->
                </div><!-- /row -->
    </section>
</section>

</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript">
    $(function() {
        //    fancybox
        jQuery(".fancybox").fancybox();
    });
</script>
<script>
    //custom select box
    $(function(){
        $('select.styled').customSelect();
    });

    $("#tianjia").click(function () {
        var id   = $("#id").val();
        var one  = $("#he_one").val();
        var two  = $("#he_two").val();
        var yu   = one%100;
        if(parseInt(one) < 100 || parseInt(yu) > 0){
            layer.open({
                title: '积分核销提示',
                content: "请输入积分大于100或者是100的整数倍！",
            });
        }else{
            if(parseInt(one)>parseInt(two)){
                layer.open({
                    title: '积分核销提示',
                    content: "输入积分超过核销上限！",
                });
            }else{
                layer.confirm('确认核销吗？确定后不可更改', {
                    title: '积分核销提示：',
                    btn: ['确定'] //可以无限个按钮
                }, function(index, layero){
                    $.ajax({
                        type:"post",
                        data:{id:id,covers:one},
                        url:"{:U('xiao')}",
                        success:function (res) {
                            if(res == 3){
                                layer.open({
                                    title: '积分核销提示',
                                    content: "核销成功",
                                });
                                location.href="__APP__/Dashboard/User/hostorys";
                            }
                            if(res == 1){
                                layer.open({
                                    title: '积分核销提示'
                                    ,content: "请输入核销积分"
                                });
                            }
                            if(res == 2){
                                layer.open({
                                    title: ''
                                    ,content: "核销失败"
                                });
                            }
                        }
                    })
                });
            }
        }
    })
</script>

</body>
</html>
